<template>
    <scroll-view v-if="list.length > 0" @scrolltolower="scrolltolower" class="scroll_view" scroll-y>
        <uni-swipe-action>
            <uni-swipe-action-item v-for="(ele, index) in list" :key="index">
                <view class="box" @tap="handleApprove(ele, 3)">
                    <view class="history">
                        <view class="history_item">
                            <RecordItem :item="ele" />
                        </view>
                    </view>

                </view>
                <template v-slot:right>
                    <!-- <view v-if="ele.status == 1" @tap.stop="handleApprove(ele, 3)" class="shenpi">审批</view> -->
                </template>

            </uni-swipe-action-item>
        </uni-swipe-action>
        <view style="padding: 10rpx 0;">
            <view class="none" v-if="isFinish">没有更多了~</view>
            <view class="loadMore" v-if="isMore">正在加载...</view>
        </view>

    </scroll-view>
    <fl-empty v-else />
</template>
  
<script setup>
import { manageExamineList } from '@/api/http'
import RecordItem from './RecordItem.vue'
import { onLoad, onShow } from "@dcloudio/uni-app";
import { ref,watch } from 'vue'
const par = {
    pageNum: 1,
    pageSize: 10
}
const list = ref([])
const total = ref(0)
const isFinish = ref(false);
const isMore = ref(false);
const props = defineProps(['isLoad'])
const getList = async () => {

    const res = await manageExamineList(par)
    total.value = res.total
    list.value = [...list.value, ...res.rows]
}
onLoad(() => {
    getList()
})
watch(() => props.isLoad, () => {
    reset()
})
const reset = () => {
    par.pageNum = 1;
    isFinish.value = false;
    isMore.value = false;
    total.value = 0;
    list.value = [];
    getList()
}
const handleApprove = (ele, type) => {
    uni.navigateTo({ url: '/pages/reporteLook/index?type=' + type + '&id=' + ele.id + '&status=' + ele.status+'&sh=1' })
}
const scrolltolower = () => {
    if (par.pageNum * par.pageSize >= total.value) {
        isFinish.value = true
        isMore.value = false
        return
    }
    par.pageNum += 1
    isMore.value = true
    getList()
}
</script>
  
<style lang="scss">
.scroll_view {
    flex: 1;
    height: 100%;
    overflow: hidden;
    background-color: #fff;

    .shenpi {
        width: 140rpx;
        display: flex;
        justify-content: center;
        align-items: center;
        background-color: #0d80d7;
        color: #fff;
    }

    .history {
        width: 88%;
        margin: 0 auto;

        .history_item {
            position: relative;
            padding: 25rpx 25rpx;
            border-bottom: 2rpx solid #E7E7E7;

            .handle {
                display: flex;
                flex-direction: column;
                position: absolute;
                height: 220rpx;
                align-items: center;
                justify-content: space-around;
                right: 0;
                top: 0;

                text {
                    display: flex;
                    text-align: center;
                    align-items: center;
                    flex: 1;
                }

            }
        }

    }
}
</style>
  